package academic.concordia.bankofquebec.entity;

import java.io.Serializable;
import java.util.Calendar;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

@Entity
@DiscriminatorValue(value="INVESTMENT_ACCOUNT")
public class SavingsAccount extends InvestmentAccount implements Serializable {

	private static final long serialVersionUID = 1L;
	
	public SavingsAccount(){
		super();
		this.attributes = AccountAttributes.SAVINGS_ACCOUNT;
		this.type = this.attributes.name();
		this.setTimePeriod(Calendar.DAY_OF_MONTH);
		this.setPeriodicity(1);
		this.setStatus(BankAccountStatus.ACTIVATED);
		this.setAnnualInterestRate(1);
		calculateInterestPaymentDate();
	}
	
	public double calculateInterests(){
		return super.calculateInterests() /365;
	}
	
	public Transaction depositInterests(double amount){
		Transaction transaction = super.depositInterests(amount);
		setInvestedAmount(getBalance());
		return transaction;
	}
	
}
